﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example4_Camera.Model
{
    class Model
    {

        const float m_rightEdge = 1;

        private Level m_level = new Level();
        private Player m_player = new Player();

        internal void Update(float a_elapsedTime)
        {
            //get a new position for the player
            m_player.Update(a_elapsedTime);


            //check level constraint
            if (m_player.GetPosition().Y > Level.g_levelHeight)
            {
                //player has penetrated floor so move him up
                m_player.SetPosition(m_player.GetPosition().X, Level.g_levelHeight);

                //slow down player
                m_player.SetSpeed(0, 0);
            }
        }

        internal bool CanJump()
        {
            //player can jump if position on the bottom of the level
            if (m_player.GetPosition().Y < Level.g_levelHeight)
            {
                return false;
            }
            return true;
        }

        internal void DoJump()
        {
            m_player.DoJump();
        }


        internal Level GetLevel()
        {
            return m_level;
        }

        internal Microsoft.Xna.Framework.Vector2 GetPlayerPosition()
        {
            return m_player.GetPosition();
        }

        internal float GetPlayerSpeed()
        {
            return m_player.GetSpeed().Length();
        }
    }
}
